<%@ page import="com.dao.BookDao" %>
<%@ page import="com.dao.MessageDao" %>
<%@ page import="com.bean.Book" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/12/11
  Time: 15:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>归还界面</title>
</head>
<body>
<%
    request.setCharacterEncoding("UTF-8");
    String book_name = request.getParameter("book_name");

    BookDao bookDao = new BookDao();
    MessageDao messageDao = new MessageDao();
    Book book = bookDao.retandborBook(book_name);
    String name = (String) session.getAttribute("name");

    int flag = messageDao.check(name, book_name);
    if (flag==1) {
        out.write("归还 《" + book_name + "》成功");
        messageDao.returnMessage(name, book_name);
        bookDao.updateBook(book, 1);
    } else {
        out.write("您的操作错误: 尚未借阅本书<br>");
    }
%>
<br><br>
<a href="/returnBook.jsp">还书</a><br>
<a href="/borrowBook.jsp">借书</a>
</body>
</html>